import axios from 'axios'

export const getListFunc = function (url, params, callBack, errorCallBack) {
    axios.get(url, {
        params: params
    }).then(function (response) {
        const data = response.data
        callBack(data)
    }).catch(function (error) {
        errorCallBack()
        console.log("网络错误")
    });
}
export const getSearchFunc = function (url, params, callBack, errorCallBack) {
    axios.get(url, {
        params: params
    }).then(function (response) {
        const data = response.data
        callBack(data)
    }).catch(function (error) {
        errorCallBack()
        console.log("网络错误")
    });
}
export const editFunc = function (url, data, callBack, errorCallBack) {
    axios.post(url, data)
        .then(function (response) {
            const data = response.data
            callBack()
        })
        .catch(function (error) {
            errorCallBack()
            console.log("网络错误")
        });
}

export const deleteFunc = function (url, data, callBack, errorCallBack) {
    axios.post(url, data)
        .then(function (response) {
            const data = response.data
            callBack()
        })
        .catch(function (error) {
            errorCallBack()
            console.log("网络错误")
        });
}

export const BatchDeleteFunc = function (url, data, callBack, errorCallBack) {
    axios.post(url, data)
        .then(function (response) {
            const data = response.data
            callBack()
        })
        .catch(function (error) {
            errorCallBack()
            console.log("网络错误")
        });
}